

import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import banking.model.Bank;

import tp.jee.BankDao;




public class TestClient {


	BankDao bdao;
	
	
	public static void main(String[] args){
		TestClient tb = new TestClient();
		tb.createDao();
		try {
			tb.test();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	private void test() {
		bdao.populate();
		List<Bank> banks = bdao.getList();
		for (Bank bank : banks) {
			System.out.println(bank);
		}
		
	}



	public void createDao() {
		System.out.println("creating  EjbDao");
		System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
				"org.jnp.interfaces.NamingContextFactory");
		System.setProperty(Context.PROVIDER_URL, "localhost:1099");
		System.setProperty(Context.URL_PKG_PREFIXES,
				"org.jboss.naming:org.jnp.interfaces");
		try {
			bdao=(BankDao) new InitialContext().lookup("BankDaoImpl/remote");
				
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}
	
	



}
